package com.xuanyang.dormrepair;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;

import javax.servlet.MultipartConfigElement;
import java.io.File;

@SpringBootApplication
public class DormRepairApplication {

    @Value("${app.temp}")
    private String temp;

    @Bean
    public MultipartConfigElement multipartConfigElement() {
        new File(temp).mkdirs(); // 创建这个临时目录
        MultipartConfigFactory factory = new MultipartConfigFactory();
        factory.setLocation(temp);
        return factory.createMultipartConfig();
    }

    public static void main(String[] args) {
        SpringApplication.run(DormRepairApplication.class, args);
    }

}
